package com.tongguan.paypos.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.tongguan.paypos.R;
import com.tongguan.paypos.base.BaseFragment;
import com.tongguan.paypos.common.AppConstants;
import com.tongguan.paypos.entity.BillsInfo;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Joylive on 2016/12/18 .
 */

public class TransBillsBelowDetailFragment extends BaseFragment {

    public static final String EXCHANGE_RESULT = "exchange_result";

    @BindView(R.id.tv_merchant_name)
    TextView mTvMerchantName;
    @BindView(R.id.tv_merchant_id)
    TextView mTvMerchantId;
    @BindView(R.id.tv_terminal_no)
    TextView mTvTerminalNo;
    @BindView(R.id.tv_card_no)
    TextView mTvCardNo;
    @BindView(R.id.tv_voucher_no)
    TextView mTvVoucherNo;
    @BindView(R.id.tv_trans_type)
    TextView mTvTransType;
    @BindView(R.id.tv_authorize_code)
    TextView mTvAuthorizeCode;
    @BindView(R.id.tv_reference_no)
    TextView mTvReferenceNo;
    @BindView(R.id.tv_batch_no)
    TextView mTvBatchNo;
    @BindView(R.id.tv_trans_time)
    TextView mTvTransTime;
    @BindView(R.id.tv_trans_amount)
    TextView mTvTransAmount;
    @BindView(R.id.button)
    Button mButton;

    private BillsInfo trans;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_bills_below_detail,container,false);
        ButterKnife.bind(this, rootView);
        Bundle extras = getArguments();
        if (extras != null) {
            trans = extras.getParcelable(EXCHANGE_RESULT);
        }
        initView();
        return rootView;
    }

    private void initView() {
        mTvMerchantName.setText(trans.getMerchantName());//?
        mTvMerchantId.setText(trans.getMerchantId());//?
        mTvTerminalNo.setText("");//?
        String cardNo = trans.getBankAccount();
        if (!TextUtils.isEmpty(cardNo)) {
            cardNo = cardNo.substring(0, 6) + "******" + cardNo.substring(cardNo.length() - 4, cardNo.length());
        }
        mTvCardNo.setText(cardNo);
        mTvVoucherNo.setText(trans.getLowOrderId());
        String state = trans.getState();
        mTvTransType.setText(AppConstants.transType.get(state));
        mTvAuthorizeCode.setText("");//?
        mTvReferenceNo.setText(trans.getUpOrderId());
        mTvBatchNo.setText("");//?
        mTvTransTime.setText(trans.getPayTime());
        mTvTransAmount.setText(String.valueOf(trans.getPayMoney()));
    }
}
